@extends('admin::layouts.master')
@section('content')
    <div class="col-lg-12">
        <div class="card card-table">
            <div class="card-header">商户管理
                <button class="btn btn-primary ml-2">商户列表</button>
                <button class="btn btn-primary" data-toggle="modal" data-target="#add">添加商户</button>
                @component('components.modal',['title' => '添加商户','url' => '/admin/user','id'=>'add'])
                    <div class="form-group">
                        <label>商户邮箱账号</label>
                        <input type="text" required placeholder="请输入商户邮箱账号，邮箱账号必须真实存在,商户只能通过邮箱登录" name="email" class="form-control">
                    </div>
                    <div class="form-group">
                        <label>商户名称</label>
                        <input type="text" required placeholder="请输入商户名称..." name="name" class="form-control">
                    </div>
                    <div class="form-group">
                        <label>登录密码</label>
                        <input type="password" required placeholder="请设置商户登录密码..." name="password" class="form-control">
                    </div>
                @endcomponent
            </div>
            <div class="card-body">
                <table class="table table-responsive" style="white-space: nowrap;">
                    <thead>
                    <tr>
                        <th>商户ID</th>
                        <th>商户邮箱</th>
                        <th>商户名称</th>
                        <th>创建时间</th>
                        <th>操作</th>

                    </tr>
                    </thead>
                    <tbody>
                    @foreach($users as $user)
                        <tr>
                            <td>{{$user['id']}}</td>
                            <td>{{$user['email']}}</td>
                            <td>{{$user['name']}}</td>
                            <td>{{$user['created_at']}}</td>
                            <td>
                                <div class="btn-group" role="group" aria-label="Basic example">
                                    <button data-toggle="modal" data-target="#useredit{{$user['id']}}" type="button" class="btn btn-success mr-2">编辑</button>
                                    @component('components.modal',['title' => '编辑用户','url' => '/admin/user/'.$user['id'],'id'=>'useredit'.$user['id'],'method'=>'PATCH'])
                                        <div class="form-group">
                                            <label>商户邮箱</label>
                                            <input type="text"  value="{{$user['email']}}" name="email" class="form-control">
                                        </div>
                                        <div class="form-group">
                                            <label>商户名称</label>
                                            <input type="text" value="{{$user['name']}}" name="name" class="form-control">
                                        </div>
                                        <div class="form-group">
                                            <label>登录密码</label>
                                            <input type="password" placeholder="如要修改请填写，否则请勿填写" name="password" class="form-control">
                                        </div>
                                    @endcomponent
                                    <form action="{{route('user.destroy',$user['id'])}}" method="post">
                                        @csrf
                                        @method('DELETE')
                                        <button type="submit" class="btn btn-danger mr-2">删除</button>
                                    </form>
                                    <a href="/admin/user/showmall/{{$user['id']}}" class="btn btn-primary">查看名下商铺</a>
                                </div>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
        {{$users->links()}}
    </div>
@endsection
